//
//  CalendarViewController.m
//  collageForZhang
//
//  Created by lht on 16-5-26.
//  Copyright (c) 2016年 zhshy. All rights reserved.
//

#import "CalendarViewController.h"
#define CELL_WIDTH (SCREENWIDTH)/8
@interface CalendarViewController ()

@end

@implementation CalendarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    self.collectionView.backgroundColor = BackgroundColor;
    self.scrollView.bounces = NO;
    [self.collectionView registerClass:[CalendarCollectionViewCell class] forCellWithReuseIdentifier:@"CalendarCollectionViewCell"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark -- UICollectionViewDataSource
//定义展示的UICollectionViewCell的个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    self.collectionView.frame = CGRectMake(0, 0, 800, 11*100);
    self.scrollView.contentSize = CGSizeMake(800, self.collectionView.frame.size.height);
    return 88;
}
//定义展示的Section的个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
//每个UICollectionView展示的内容
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    UINib *nib = [UINib nibWithNibName:@"CalendarCollectionViewCell" bundle: [NSBundle mainBundle]];
    [collectionView registerNib:nib forCellWithReuseIdentifier:@"CalendarCollectionViewCell"];
    CalendarCollectionViewCell *cell = (CalendarCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CalendarCollectionViewCell" forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor whiteColor];
    [cell.layer setMasksToBounds:YES];
    cell.layer.borderColor= BorderLineColor;
    cell.layer.borderWidth=0.75f;
    switch (row) {
        case 0:
            cell.titleLbl.text = @"";
            break;
        case 1:
            cell.titleLbl.text = @"星期一";
            break;
        case 2:
            cell.titleLbl.text = @"星期二";
            break;
        case 3:
            cell.titleLbl.text = @"星期三";
            break;
        case 4:
            cell.titleLbl.text = @"星期四";
            break;
        case 5:
            cell.titleLbl.text = @"星期五";
            break;
        case 6:
            cell.titleLbl.text = @"星期六";
            break;
        case 7:
            cell.titleLbl.text = @"星期日";
            break;
        default:
            break;
    }
    if (row%8==0) {
        if (row>0) {
            cell.titleLbl.text = @"老师姓名";
        }
    }
    
    return cell;
}
#pragma mark --UICollectionViewDelegateFlowLayout
//定义每个UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(100, 100);
}
//定义每个UICollectionView 的 margin
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
#pragma mark --UICollectionViewDelegate
//UICollectionView被选中时调用的方法
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
}
//返回这个UICollectionView是否可以被选择
-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}
@end
